1. Field of the Invention
The present invention relates to techniques for managing Input/Output (I/O) operations within a computer system. More specifically, the present invention relates to a method and an apparatus for performing independent asynchronous I/O operations within a platform-independent virtual machine within a computer system.
2. Related Art
The exponential growth of the Internet has in part been fueled by the development of computer languages, such as the JAVA™ programming language distributed by Sun Microsystems, Inc. of Santa Clara, Calif. The JAVA programming language allows an application to be compiled into a module containing platform-independent byte codes, which can be distributed across a network of many different computer systems. Any computer system possessing a corresponding platform-independent virtual machine, such as the JAVA virtual machine, is then able to execute the byte codes. In this way, a single form of an application can be easily distributed to and executed by a large number of different computing platforms.
These platform-independent virtual machines are presently being incorporated into smaller pocket-sized computing devices, such as personal organizers. Unfortunately, memory space is severely constrained within these pocket-sized computing devices. Hence, system designers must use as little memory space as possible in implementing virtual machines within these pocket-sized computing devices.
Platform independent virtual machines typically provide run-time support for multiple “language threads” (L-threads). For example the JAVA virtual machine supports the execution of multiple JAVA threads. In larger computer systems it is practical to implement L-threads using a one-to-one mapping with underlying operating system threads (OS-threads). However, memory-constrained computing devices often lack the virtual memory capabilities to make this possible. Furthermore, a one-to-one mapping requires a large number of OS-threads, which can consume a large amount of memory space.
For this reason, in memory-constrained systems L-threads are often implemented as co-routines that share a single OS-thread. Unfortunately, if multiple L-threads share a single OS-thread, implementing I/O operations can be a problem because an I/O operation can potentially cause the single OS-thread to block, even if other L-threads are waiting to perform useful work. To remedy this problem, some systems pair an L-thread with an extra OS-thread during the time the L-thread is performing an I/O operation. In way, the extra OS-thread can perform the I/O operation on behalf of the L-thread, and the L-thread is de-scheduled until the OS-thread completes the I/O operation. After the I/O operation completes, the OS-thread is returned to the shared pool, which allows the OS-thread to be reused.
In order to perform the I/O operation, the OS-thread typically manipulates parameters for the I/O operation located in an object heap within the virtual machine. This creates problems because the object heap is typically subject to periodic garbage collection operations, which can potentially move the parameters within the object heap. Hence, the OS-thread must acquire a garbage collection (GC) lock while accessing the object heap to ensure that garbage collection operations do not cause the OS-thread to access the wrong locations in the object heap. Moreover, allowing the OS-thread to access the object heap generally reduces system reliability because the OS-thread can potentially corrupt the object heap.
Hence, what is needed is a method and an apparatus for performing I/O operations within a platform-independent virtual machine without the problems listed above.